<template>
  <!-- 查看库存明细 -->
  <div>
    <FilterTable
      ref="table"
      columnsRef="part_partPurchase_queryR3DialogTable"
      :dataSource="dataList"
      :isMemoryPagination="true"
      :fetchapi="fetchapi"
      :params="fetchParams"
      :isSelectColumn="false"
      :columns="tableColumns"
      :datakey="'rows'"
      :onColumnsChange="columns => (this.tableColumns = columns)"
    >
      <!-- <template slot="controls">
        <el-button size="small" type="primary">导出</el-button>
        <el-button size="small" type="primary">打印</el-button>
      </template>-->
    </FilterTable>
    <div class="bottomBtnWrap">
      <el-button @click="handleClose">关 闭</el-button>
      <!--  <el-button @click="handleConfirm" type="primary">确 定</el-button> -->
    </div>
  </div>
</template>

<script>
import { quertR3Log, queryAllOrderTypeInfo } from '@/api/part/partPurchase/purchaseOrder';
import { getPartUploadSPPDetailDatas } from '@/api/part/inventoryManager/partUpdateSPP';

export default {
  props: {
    fetchapi: Function,
    rowData: Array
  },
  data() {
    return {
      tableColumns: this.createTableColumns(),
      // orderTypeList: {}, //所有订单类型(翻译用)
      fetchParams: { xhrAbort: true },
      dataList: [] // 日志列表
    };
  },
  created() {
    this.initSearch();
  },
  mounted() {
    // this.$nextTick(() => {
    // this.queryUploadSPPDetailList();
    // this.queryAllOrderTypeInfoList();
    // });
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '订货申请单号',
          dataIndex: 'VBELN',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '订货行项号',
          dataIndex: 'POSNR',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '清关日期',
          dataIndex: 'ZQGRQ',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '发票日期',
          dataIndex: 'ZFPRQ',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '入库日期',
          dataIndex: 'ZRKRQ',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '送库日期',
          dataIndex: 'ZSKRQ',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '采购日期',
          dataIndex: 'ZCGRQ',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件号',
          dataIndex: 'MATNR',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    // 查询所有订单类型
    async queryAllOrderTypeInfoList() {
      let res = await queryAllOrderTypeInfo();
      let obj = {};
      res.data.map(item => {
        obj[item.partTypeNo] = item.partTypeName;
      });
      this.orderTypeList = obj;
    },
    // 查询r3列表
    async queryUploadSPPDetailList() {
      this.$refs.table.START_LOADING();
      let res = await getPartUploadSPPDetailDatas();
      this.$refs.table.STOP_LOADING();
      if (res.resultCode == 200) {
        this.dataList = res.data;
      }
    },
    // 初始化查询
    initSearch() {
      console.log(this.rowData, 12321);

      this.fetchParams = {
        I_VBELN: this.rowData[0].QVBELN,
        xhrAbort: false
      };
    },
    // 点击搜索条件搜索或者重置
    handleSearch(e) {
      this.fetchParams.xhrAbort = true;
      this.fetchParams = Object.assign(this.fetchParams, {
        xhrAbort: false,
        partTypeNo: this.orderType,
        ...e
      });
    },
    handleClose() {
      this.$emit('close');
    }
  }
};
</script>

<style scoped>
.bottomBtnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
</style>
